<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="__ROOT__/Public/Admin/css/shortcut icon" href="favicon.ico">
    <link href="__ROOT__/Public/Admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/animate.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/js/plugins/cityPicker/city-picker.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/js/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/edit.css" rel="stylesheet"/>

<style>
.loading{
			 width: 35px;
			 height: 35px;
			 margin: 0 auto;
			 margin-top:100px;
			 position: fixed;
			 top: 0px;
			 left: 0px;
			 right: 0px;
			 bottom: 0px;
			 margin: auto;
		}
</style>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       
        <div class="row">
            <form class="form-horizontal m-t js-ajax-forms" id="signupForm" action="{:U('Admin/ProjectGL/save')}<if condition="$editdata">&type=update<else />&type=add</if>" method="post" enctype="multipart/form-data">
           	<input type="hidden" name="ID" value="{$editdata['ID']}">
           	<input type="hidden" class="taskID" name="TID" value="">
            <div class="col-sm-8  col-md-offset-2">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目名称 * </label>
                                <div class="col-sm-8">
                                    <input id="Name" name="Name" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error" value="{$editdata.Name}">
                                </div>
                            </div>
                            
                            <!-- div class="form-group">
                                <label class="col-sm-3 control-label">任务名称</label>
                                <div class="col-sm-8">
                                    <select type="hidden" class="form-control" id="TID" name="TID" aria-required="true" aria-invalid="true" class="error">
                                        <option value="">请选择任务</option>
                                        <foreach name="data.selectlist.TID" item="vo">
                                        	<option <if condition="$vo.ID eq $editdata['TID']"> selected  </if> value="{$vo.ID}">{$vo.Name}</option>
										</foreach>
                                    </select>
                                </div>
                            </div -->
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目类型</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="ProjectType" name="ProjectType" aria-required="true" aria-invalid="true" class="error">
                                        <option value="">请选择项目类型</option>
                                        <foreach name="data.selectlist.ProjectType" item="vo">
                                        	<option <if condition="$vo.ID eq $editdata['ProjectType']"> selected  </if> value="{$vo.ID}">{$vo.Name}</option>
										</foreach>
                                    </select>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目规模</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="Scale" name="Scale" aria-required="true" aria-invalid="true" class="error">
                                        <option value="">请选择项目规模</option>
                                        <foreach name="data.selectlist.Scale" item="vo">
                                        	<option <if condition="$vo.ID eq $editdata['Scale']"> selected   </if> value="{$vo.ID}">{$vo.Name}</option>
										</foreach>
                                    </select>
                                </div>
                            </div>
                            
	                        <div class="form-group">
                                <label class="col-sm-3 control-label">资金来源</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="FundSource" name="FundSource" aria-required="true" aria-invalid="true" class="error">
                                        <option value="">请选择资金来源</option>
                                        <foreach name="data.selectlist.FundSource" item="vo">
                                        	<option <if condition="$vo.ID eq $editdata['FundSource']"> selected   </if> value="{$vo.ID}">{$vo.Name}</option>
										</foreach>
                                    </select>
                                </div>
                            </div>
	                        
                            <div class="form-group">
                                <label class="col-sm-3 control-label">客户名称*</label>
                                <div class="col-sm-8">
                                    <input id="Customer" name="Customer" class="form-control" type="text"  value="{$editdata.Customer}">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">申报人</label>
                                <div class="col-sm-8">
                                	<input id='ApplyUserID' name='ApplyUserID' value="{$editdata.ApplyUserID}" type="hidden">
                                    <input id="ApplyUserName" name="ApplyUserName" class="form-control selector-icon"  onclick="openselector('ApplyUserID','ApplyUserName')" data-toggle="modal" data-target="#myModal" type="text"  value="{$editdata.ApplyUserName}">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目组织</label>
                                <div class="col-sm-8">
                                	<input id='DepID' name='DepID' value="{$editdata.DepID}" type="hidden">
                                	<input id="DepName" name="DepName" class="form-control selector-icon"  onclick="openselector('DepID','DepName')" data-toggle="modal" data-target="#myModal" type="text"  value="{$editdata.DepName}">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目负责人</label>
                                <div class="col-sm-8">
                                	<input id='ChargeUserID' name='ChargeUserID' value="{$editdata.ChargeUserID}" type="hidden">
                                	<input id="ChargeUserName" name="ChargeUserName" class="form-control selector-icon"  onclick="openselector('ChargeUserID','ChargeUserName')" data-toggle="modal" data-target="#myModal" type="text"  value="{$editdata.ChargeUserName}">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目分管领导</label>
                                <div class="col-sm-8">
                                    <input id='LeaderUserID' name='LeaderUserID' value="{$editdata.LeaderUserID}" type="hidden">
                                	<input id="LeaderUserName" name="LeaderUserName" class="form-control selector-icon"  onclick="openselector('LeaderUserID','LeaderUserName')" data-toggle="modal" data-target="#myModal" type="text"  value="{$editdata.LeaderUserName}">
                                	
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目实施地点</label>
                                <div class="col-sm-8">
                                    <input id="Place" name="Place" class="form-control" type="text" value="{$editdata.Place}">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目所处状态*</label>
                                <div class="col-sm-8">
                                    <select id="Status" name="Status" class="form-control" id="LeaderUserID" name="LeaderUserID" aria-required="true" aria-invalid="true" class="error">
                                    	<option value="">请选择项目状态</option>
                                        <foreach name="data.selectlist.Status" item="vo">
                                        	<option <if condition="$vo.ID eq $editdata['Status']"> selected   </if> value="{$vo.ID}">{$vo.Name}</option>
										</foreach>
                                    </select>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目重点节点</label>
                                <div class="col-sm-8">
                                    <textarea id="ImportantPoint" name="ImportantPoint" class="form-control diff-textarea" rows="6">{$editdata.ImportantPoint}</textarea>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目概况</label>
                                <div class="col-sm-8">
                                    <textarea id="Intro" name="Intro" class="form-control diff-textarea" rows="6">{$editdata.Intro}</textarea>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">项目内容</label>
                                <div class="col-sm-8">
                                    <textarea id="Content" name="Content" class="form-control diff-textarea" rows="6">{$editdata.Content}</textarea>
                                </div>
                            </div>
                            
                            <div class="form-group has-success">
                                <label class="col-sm-3 control-label" style="color:#686b6d">项目开始日期</label>
                                <div class="col-sm-8">
                                    <input style="border-color:#cfdadd" type="text" id="StartDate" name="StartDate" class="form-control date laydate-icon"" value="{$editdata.StartDate}">
                                </div>
                            </div>

                            <div class="form-group has-success">
                                <label class="col-sm-3 control-label" style="color:#686b6d">项目结束日期</label>
                                <div class="col-sm-8">
                                    <input style="border-color:#cfdadd" type="text" id="EndDate" name="EndDate" class="form-control date laydate-icon"" value="{$editdata.EndDate}">
                                </div>
                            </div>
                            
                            <div class="form-group has-success">
                                <label class="col-sm-3 control-label" style="color:#686b6d">项目生效日期</label>
                                <div class="col-sm-8">
                                	<input style="border-color:#cfdadd" type="text" id="ValidDate" name="ValidDate" class="form-control date laydate-icon"" value="{$editdata.ValidDate}">
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary keep" type="submit">保存</button>
                                    <?php if(empty($formid)){ ?>
                                    	 <a class="btn btn-white" href="javascript:void(0);" onclick="self.location=document.referrer;">返回</a>	
                                 	<?php } ?>                                   
                                </div>
                            </div>
                        
                    </div>
                </div>
            </div>
           
            </form>
        </div>
    </div>
        <img src="__ROOT__/Public/Admin/img/loading.gif" class="loading" style="display:none;">	

	

	<script src="__ROOT__/Public/Admin/js/jquery.min.js"></script>
	<script src="__ROOT__/Public/Admin/js/bootstrap.min.js"></script>
	<script src="__ROOT__/Public/Admin/js/plugins/layer/laydate/laydate.js"></script>
	<script src="__ROOT__/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
	<script src="__ROOT__/Public/Admin/js/ajaxForm.js"></script>
	<script src="__ROOT__/Public/Admin/js/plugins/sweetalert/sweetalert.min.js"></script>
	
	<link href="__ROOT__/Public/Admin/css/selector/selectorstyle.css" rel="stylesheet"/>
	<script src="__ROOT__/Public/Admin/js/plugins/selector/selector.js"></script>
 	<script src="__ROOT__/Public/Admin/js/plugins/selector/jquery.ztree.all.js"></script>
 	<script src="__ROOT__/Public/Admin/js/plugins/layer/layer.min.js"></script>
 	
	<script>
		var taskID = parent.taskID;
		$(document).ready(function () {
			var icon = "<i class='fa fa-times-circle'></i>";
			var form = $('form.js-ajax-forms');
			var formloading = false;
			form.validate({
		        //验证规则
		        rules: {
		            Name: {
		                required: true
		            },
		            Customer: {
		                required: true
		            },
		            Status: {
		                required: true
		            }
		        },
		        //验证未通过提示消息
		        messages: {
		            Name:{
		                required: icon + "请输入项目名称"
		            },
		            Customer:{
		                required: icon + "请输入客户名称"
		            },
		            Status:{
		                required: icon + "请选择项目状态"
		            }
		        },
		        //验证通过，提交表单
		        submitHandler : function(forms) {
		        	if (formloading)
	                return;
		            $(forms).ajaxSubmit({
		                url : form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
		                dataType : 'json',
		                beforeSubmit : function(arr, $form, options) {
		                    formloading = true;
		                },
		                success : function(data, statusText, xhr, $form) {
		                    formloading = false;
		                    if (data.status) {
		                        //添加成功
		                        swal({
		                            title: "继续操作？",
		                            text: "操作成功！",
		                            type: "success",
		                            showCancelButton: true,
		                            confirmButtonColor: "#DD6B55",
		                            confirmButtonText: "确认",
		                            cancelButtonText: "返回",
		                            closeOnConfirm: false,
		                            closeOnCancel: false
		                        },
		                        function (isConfirm) {
		                        	if(taskID != null){
		                        		document.location.reload();
		                        		return;
		                        	}
		                            if (isConfirm) {
		                                document.location.reload();
		                            } else {
		                                document.location.href = "{:U('ProjectGL/index')}";
		                                return true;
		                            }
		                        }); 
		                    } else {
		                        swal("操作失败", data.info, "error");
		                    }
		                }
		            });
		        }
		    });
		});


		var EndDate = {
            elem: '#EndDate',
            format: 'YYYY-MM-DD',
            min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
               
            }
        };
        laydate(EndDate);
        var StartDate = {
            elem: '#StartDate',
            format: 'YYYY-MM-DD',
            min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
               
            }
        };
        laydate(StartDate);
        var ValidDate = {
            elem: '#ValidDate',
            format: 'YYYY-MM-DD',
            min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {

            }
        };
        laydate(ValidDate); 
        
        
        
        //办理过程
        var busid = '{$busid}';
		var formid = '{$formid}';
		
        if(busid != null){
        	data = {
        		"busid":busid,
        		"formid":formid
        	}
			$(".loading").show();
        	$.post("{:U('Admin/TaskProcess/getRihtByXid')}",data,function(result){
        		$(".loading").hide();
        		for(var k in result){
        			switch(result[k].RightType){
        				case "0":
        					$("#"+result[k].IDName).parent().parent().css("display","none");
        					break;
        				case "1":
        					$("#"+result[k].IDName).attr("readonly",true);
        					$("#"+result[k].IDName).attr("disabled",true);
        					$("#"+result[k].IDName).attr("class","form-control");
        					break;
        				case "2":
        					break;
        				default:
        					break;
        			}
        		}
        	});
        }
        if(taskID != null){
        	$(".taskID").val(taskID);
        }
	</script>
	<script src="__ROOT__/Public/Admin/js/TaskProcess.js"></script>
</body>

</html>
